<template>
  <a-layout>
    <a-layout-header class="bg-white admin-content-header">
      <div class="col-4 admin-tiao-left">
        <span>{{ $route.name }}</span>
      </div>
      <div class="col-8 text-right">
        <el-button-group>
          <el-button type="primary" @click="dialogFormVisible = true" icon="el-icon-edit">添加iframe</el-button>
        </el-button-group>
      </div>
      <el-dialog title="添加课程" :visible.sync="dialogFormVisible">
        <el-form :model="form">
          <el-form-item label="名称">
            <el-input v-model="form.name" autocomplete="off"></el-input>
          </el-form-item>
          <el-form-item label="url">
            <el-input v-model="form.url" autocomplete="off"></el-input>
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button @click="dialogFormVisible = false">取 消</el-button>
          <el-button type="primary" @click="onSubmit">确 定</el-button>
        </div>
      </el-dialog>
    </a-layout-header>
    <a-layout-content class="admin-content-table">
      <el-table height="100%" :data="getIframe" border style="width: 100%" max-height="720">
        <el-table-column type="selection" width="55"></el-table-column>
        <el-table-column fixed prop="ID" sortable label="ID" width="150"></el-table-column>
        <el-table-column fixed prop="name" label="名称" width="180"></el-table-column>
        <el-table-column prop="url" label="网页路径" width="120">
          <template slot-scope="scope">
            <a :href="scope.row.url" v-text="scope.row.name" target="_blank"></a>
          </template>
        </el-table-column>
      </el-table>
    </a-layout-content>
  </a-layout>
</template>

<script>
import { mapGetters } from "vuex";
import { asynccreateiframe } from "../../../plugins/api.js";
export default {
  name: "ifreams",
  data() {
    return {
      name: "查看",
      paths: [],
      num1: 0,
      dialogFormVisible: false,
      loading: false,
      form: {
        name: "",
        url: ""
      }
    };
  },
  computed: mapGetters(["getIframe"]),
  methods: {
    async onSubmit() {
      try {
        await asynccreateiframe(this.form);
        this.$message({
          message: "恭喜你，修改成功",
          type: "success"
        });
        this.dialogFormVisible = false;
        this.$store.dispatch("actionIframe");
      } catch (err) {
        this.$message.error("错了哦，修改失败:" + err);
      }
    }
  }
};
</script>

<style scoped>
</style>